{include file="public/head"/}
<link rel="stylesheet" href="__LAYADMIN__/style/dtree.css" media="all">
<link rel="stylesheet" href="__LAYADMIN__/style/font/dtreefont.css" media="all">
<style>
    #demoTree{padding-top: 5px;}
    #demoTree>li{padding-left: 0;}
</style>
<div class="layui-fluid" id="LAY-app-message">
    <div class="layui-card">
        <div class="layui-card-header">分配权限</div>
        <div class="layui-card-body">
            <div class="layui-row">
                <!-- 此扩展能递归渲染一个权限树，点击深层次节点，父级节点中没有被选中的节点会被自动选中，单独点击父节点，子节点会全部 选中/去选中 -->
                <div class="layui-form">
                    <div class="layui-form-item">
                        <label class="layui-form-label">分组名称：</label>
                        <div class="layui-form-mid">
                            {$info.title}
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">选择权限：</label>
                        <div class="layui-input-block">
                            <div id="test1"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input name="id" type="hidden" value="{$info.id}">
                            <button class="layui-btn" lay-submit lay-filter="submit">确认保存</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/foot"/}

<script>
    layui.config({
        base: '__LAYADMIN__/',
        version: true
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','tree','form'],function(){
        var $ = layui.$,admin = layui.admin,tree = layui.tree,form = layui.form;
        var data = {$menus|raw};
        tree.render({
            elem: '#test1',
            data:data,
            showCheckbox: true
        });
        //提交编辑
        form.on('submit(submit)', function(data){
            admin.req({
                url: '/admin/auth/groupSetaccess'
                , type: 'post'
                , data: data.field
                , done: function (res) {
                    layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                        layer.closeAll("iframe");
                        //刷新父页面
                        parent.location.reload();
                    });
                }
            });
        });
    });
</script>
</body>
</html>